//
//  VerifyPhonePage.swift
//  Uber
//
//  Created by chen on 16/3/15.
//  Copyright © 2016年 chen. All rights reserved.
//

import UIKit

class VerifyPhonePage: FxBasePage {
    @IBOutlet weak var firstNumber:UITextField!
    @IBOutlet weak var secondNumber:UITextField!
    @IBOutlet weak var thirdNumber:UITextField!
    @IBOutlet weak var forthNumber:UITextField!

    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "确认手机号码"
        

        // Do any additional setup after loading the view.
    }
    @IBAction func doVerify(){
        self.showIndicator("验证中...", autoHide: true, afterDelay: true)
        self.performSelector("showHomePage", withObject: self, afterDelay: 1.0)
    }
    @IBAction func doChangeTextField(textField:UITextField){
        let tag = textField.tag
        //需要考虑两种情况，删除一个数字，和添加一个数字时。
        if (textField.text?.isEmpty == false){
            if tag < 4{
                let textField = self.view.viewWithTag(tag + 1) as! UITextField
                textField.becomeFirstResponder()
            }else {
                let textField = self.view.viewWithTag(tag) as! UITextField
                textField.resignFirstResponder()
            }
        }else{
            if tag != 0 {
                let textField = self.view.viewWithTag(tag - 1) as! UITextField
                textField.becomeFirstResponder()
            }else{
                
            }
        }
        
    }
    func showHomePage(){
        let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
        appDelegate.showHomePage()
    }
    

}
